package server

import (
	"JudgeClient/rsync"
	"JudgeClient/utils"
	"github.com/gin-gonic/gin"
	"net/http"
)

func SyncTestCase(c *gin.Context) {
	if !utils.CheckToken(c.GetHeader("Token")) {
		c.JSON(http.StatusOK, gin.H{
			"code": -1,
			"data": "wrong token",
		})
		return
	}
	testcaseId := c.Query("tid")
	var err error
	if testcaseId != "" {
		if err = rsync.SyncSingle(testcaseId); err == nil {
			c.JSON(http.StatusOK, gin.H{
				"code": 0,
			})
			return
		}
	}
	c.JSON(http.StatusOK, gin.H{
		"code": -1,
		"data": err,
	})
	return
}
